#ifndef __H_APPLICATION__
#define __H_APPLICATION__

#include "tstring.h"

namespace bl{

	class Application
	{
	public:
		static tstring GetApplicationName()
		{
			tchar name[MAX_PATH];
			::GetModuleFileName(NULL, name, MAX_PATH);
			return name;
		}

		static tstring GetApplicationPath()
		{
			tstring name = GetApplicationName();
			
			tstring path(name, 0, name.rfind(TEXT('\\'))+1 );
			return path;
		}

		static tstring GetModulePath()
		{
			tchar name[MAX_PATH];
			::GetModuleFileName(ModuleFromAddress(ModuleFromAddress), name, MAX_PATH);
			tstring strName(name);
			tstring path(name, 0, strName.rfind(TEXT('\\'))+1 );
			return path;
		}

	private:
		static HMODULE ModuleFromAddress(PVOID pv)
		{
			MEMORY_BASIC_INFORMATION   mbi;  
			return((VirtualQuery(pv,   &mbi,   sizeof(mbi))   !=   0)     
				?  (HMODULE)   mbi.AllocationBase   :   NULL);  
		}
	};


}


#endif